import os
import pickle
from collections import OrderedDict

from dassl.data.datasets import DATASET_REGISTRY, Datum, DatasetBase
from dassl.utils import listdir_nohidden, mkdir_if_missing

from .add_noise import generate_fewshot_dataset_with_symflip_noise, generate_fewshot_dataset_with_pairflip_noise

from .oxford_pets import OxfordPets


@DATASET_REGISTRY.register()
class ImageNet(DatasetBase):

    dataset_dir = "imagenet"

    def __init__(self, cfg):
        root = os.path.abspath(os.path.expanduser(cfg.DATASET.ROOT))
        self.dataset_dir = os.path.join(root, self.dataset_dir)
        self.image_dir = os.path.join(self.dataset_dir, "images")
        self.preprocessed = os.path.join(self.dataset_dir, "preprocessed.pkl")
        self.split_fewshot_dir = os.path.join(self.dataset_dir, "split_fewshot")
        mkdir_if_missing(self.split_fewshot_dir)

        if os.path.exists(self.preprocessed):
            
            with open(self.preprocessed, "rb") as f:
                preprocessed = pickle.load(f)
                train = preprocessed["train"]
                test = preprocessed["test"]
        else:
            text_file = os.path.join(self.dataset_dir, "classnames.txt")
            classnames = self.read_classnames(text_file)
            train = self.read_data(classnames, "train")
            # Follow standard practice to perform evaluation on the val set
            # Also used as the val set (so evaluate the last-step model)
            test = self.read_data(classnames, "val")

            preprocessed = {"train": train, "test": test}
            with open(self.preprocessed, "wb") as f:
                pickle.dump(preprocessed, f, protocol=pickle.HIGHEST_PROTOCOL)

        # generate the ground truth labels
        self.gt_labels = {}
        for sample in train:
            self.gt_labels[sample.impath] = sample.label

        # generate the noisy labels
        num_shots = cfg.DATASET.NUM_SHOTS
        num_fp = cfg.DATASET.NUM_FP
        fp_type = cfg.DATASET.FP_TYPE
        self.split_fewshot_dir = os.path.join(self.dataset_dir, "split_fewshot", f"shots_{num_shots}_{fp_type}")
        mkdir_if_missing(self.split_fewshot_dir)
        if num_shots >= 1:
            seed = cfg.SEED
            preprocessed = os.path.join(self.split_fewshot_dir, f"fp_{num_fp}-seed_{seed}.pkl")

            if os.path.exists(preprocessed):
                print(f"Loading preprocessed few-shot data from {preprocessed}")
                with open(preprocessed, "rb") as file:
                    data = pickle.load(file)
                    train, val = data["train"], data["val"]
                    # for item in train:
                    #     print(item.label, item.impath, item.classname)
            else:
                if fp_type == "symflip":
                    train = generate_fewshot_dataset_with_symflip_noise(train, num_shots=num_shots,
                                                                         num_fp=num_fp, seed=seed)
                elif fp_type == "pairflip":
                    train = generate_fewshot_dataset_with_pairflip_noise(train, num_shots=num_shots,
                                                                         num_fp=num_fp, seed=seed)
                else:
                    raise ValueError(f"There is no such type of noise!")
                val = test
                data = {"train": train, "val": val}
                print(f"Saving preprocessed few-shot data to {preprocessed}")
                with open(preprocessed, "wb") as file:
                    pickle.dump(data, file, protocol=pickle.HIGHEST_PROTOCOL)
        
        subsample = cfg.DATASET.SUBSAMPLE_CLASSES
        train, val, test = OxfordPets.subsample_classes(train, val, test, subsample=subsample)

        super().__init__(train_x=train, val=val, test=test)
    
    @property
    def features(self):
        return {
            'tench': "which has a slender body and a greenish hue.",
            'goldfish': "which is small, orange, and commonly kept in aquariums.",
            'great white shark': "which is large, predatory, and has a white underside.",
            'tiger shark': "which has distinctive stripes and is known for aggressiveness.",
            'hammerhead shark': "which has a unique hammer-shaped head and sharp teeth.",
            'electric ray': "which has a flat body and can deliver electric shocks.",
            'stingray': "which has a flat body and long, whip-like tail.",
            'rooster': "which is a male chicken known for its crowing.",
            'hen': "which is a female chicken known for laying eggs.",
            'ostrich': "which is a large flightless bird with long legs.",
            'brambling': "which has a colorful plumage and is a small finch.",
            'goldfinch': "which is small, vibrant yellow, and loves seeds.",
            'house finch': "which is small and often seen in urban areas.",
            'junco': "which is small and has a distinctive dark head.",
            'indigo bunting': "which is bright blue and migrates long distances.",
            'American robin': "which has a red breast and is often seen in gardens.",
            'bulbul': "which has a cheerful song and is found in gardens.",
            'jay': "which is colorful and known for its intelligence.",
            'magpie': "which is known for its black and white plumage.",
            'chickadee': "which is small, social, and has a distinctive call.",
            'American dipper': "which can walk underwater and is found near streams.",
            'kite (bird of prey)': "which has a slender body and graceful flight.",
            'bald eagle': "which has a white head and is a national symbol.",
            'vulture': "which is scavenger with a bald head and strong beak.",
            'great grey owl': "which is large with a rounded face and tufted ears.",
            'fire salamander': "which is black with yellow spots and toxic.",
            'smooth newt': "which has a smooth skin and aquatic habitat.",
            'newt': "which is small, semi-aquatic, and has a long tail.",
            'spotted salamander': "which has black skin with yellow or white spots.",
            'axolotl': "which has external gills and remains aquatic as adult.",
            'American bullfrog': "which is large and known for its loud croak.",
            'tree frog': "which has adhesive pads for climbing and is small.",
            'tailed frog': "which has a distinctive tail and lives in streams.",
            'loggerhead sea turtle': "which has a large head and is found in oceans.",
            'leatherback sea turtle': "which is the largest and has a leathery shell.",
            'mud turtle': "which has a domed shell and prefers muddy habitats.",
            'terrapin': "which lives in brackish waters and has a patterned shell.",
            'box turtle': "which has a hinged shell allowing it to close tightly.",
            'banded gecko': "which is small, colorful, and known for its patterns.",
            'green iguana': "which is large, green, and often kept as a pet.",
            'Carolina anole': "which can change color and has a long tail.",
            'desert grassland whiptail lizard': "which is fast and prefers sandy environments.",
            'agama': "which is a colorful lizard often basking in the sun.",
            'frilled-necked lizard': "which has a distinctive frill around its neck.",
            'alligator lizard': "which has a long body and is often seen in gardens.",
            'Gila monster': "which is venomous and has a distinctive pattern.",
            'European green lizard': "which is vibrant green and loves sunny areas.",
            'chameleon': "which can change color and has a prehensile tail.",
            'Komodo dragon': "which is the largest lizard and a powerful predator.",
            'Nile crocodile': "which is large and often found in freshwater habitats.",
            'American alligator': "which has a broad snout and prefers freshwater.",
            'triceratops': "which is a dinosaur with three facial horns.",
            'worm snake': "which is small, burrowing, and resembles a worm.",
            'ring-necked snake': "which has a distinctive yellow ring around its neck.",
            'eastern hog-nosed snake': "which is known for its distinctive upturned snout.",
            'smooth green snake': "which is small, slender, and bright green.",
            'kingsnake': "which is known for its striking patterns and colors.",
            'garter snake': "which is common and often has longitudinal stripes.",
            'water snake': "which is semi-aquatic and has a thick body.",
            'vine snake': "which is slender, green, and camouflaged among leaves.",
            'night snake': "which is nocturnal and prefers dry habitats.",
            'boa constrictor': "which is large and constricts its prey.",
            'African rock python': "which is massive and known for its strength.",
            'Indian cobra': "which is venomous and has a distinctive hood.",
            'green mamba': "which is fast and highly venomous.",
            'sea snake': "which is adapted to marine life and has a flattened tail.",
            'Saharan horned viper': "which has distinctive horns and camouflages in sand.",
            'eastern diamondback rattlesnake': "which is large and known for its rattling sound.",
            'sidewinder rattlesnake': "which moves sideways on sand and has a distinctive pattern.",
            'trilobite': "which is an extinct marine arthropod with a segmented body.",
            'harvestman': "which has long legs and is not a true spider.",
            'scorpion': "which has a segmented tail and pincers for defense.",
            'yellow garden spider': "which has yellow markings and spins large webs.",
            'barn spider': "which builds large orb webs and is common.",
            'European garden spider': "which has distinctive markings and spins intricate webs.",
            'southern black widow': "which is venomous and has a distinctive red hourglass.",
            'tarantula': "which is large, hairy, and often kept as a pet.",
            'wolf spider': "which hunts actively and has excellent eyesight.",
            'tick': "which is a small parasitic arachnid that feeds on blood.",
            'centipede': "which has many legs and is fast-moving.",
            'black grouse': "which is a large game bird with a distinctive tail.",
            'ptarmigan': "which is a bird that changes color with the seasons.",
            'ruffed grouse': "which is a forest bird known for its drumming display.",
            'prairie grouse': "which inhabits open grasslands and performs elaborate displays.",
            'peafowl': "which is known for its iridescent feathers and courtship displays.",
            'quail': "which is small, ground-dwelling, and often found in grasslands.",
            'partridge': "which is a game bird with a distinctive call.",
            'african grey parrot': "which is intelligent, grey, and known for mimicking speech.",
            'macaw': "which is large, colorful, and often kept as a pet.",
            'sulphur-crested cockatoo': "which has a prominent crest and is very social.",
            'lorikeet': "which has a specialized diet of nectar and fruit.",
            'coucal': "which has a long tail and is known for its calls.",
            'bee eater': "which is colorful and feeds primarily on insects.",
            'hornbill': "which has a large bill and often nests in tree cavities.",
            'hummingbird': "which is tiny, colorful, and capable of hovering.",
            'jacamar': "which has vibrant plumage and catches insects mid-air.",
            'toucan': "which has a large, colorful bill and is tropical.",
            'duck': "which is a waterfowl known for its quacking sound.",
            'red-breasted merganser': "which is a diving duck with a distinctive red breast.",
            'goose': "which has a long neck and a honking call.",
            'black swan': "which has striking black feathers and red bill.",
            'tusker': "which has large, visible tusks protruding from its mouth.",
            'echidna': "which has spiny back and lays eggs like a bird.",
            'platypus': "which has webbed feet and a duck-like bill.",
            'wallaby': "which has a smaller body than a kangaroo.",
            'koala': "which has fluffy ears and a diet of eucalyptus leaves.",
            'wombat': "which has a stocky build and burrows in the ground.",
            'jellyfish': "which has a gelatinous, umbrella-shaped body and tentacles.",
            'sea anemone': "which has a colorful, flower-like appearance with tentacles.",
            'brain coral': "which has a textured surface resembling a human brain.",
            'flatworm': "which has a soft, flattened body and no body cavity.",
            'nematode': "which has a cylindrical body and is often microscopic.",
            'conch': "which has a large, spiral shell and is edible.",
            'snail': "which has a soft body and a coiled shell.",
            'slug': "which has a soft, slimy body without a shell.",
            'sea slug': "which has bright colors and a soft, unprotected body.",
            'chiton': "which has eight overlapping plates on its dorsal side.",
            'chambered nautilus': "which has a coiled shell divided into chambers.",
            'Dungeness crab': "which has a hard shell and sweet, tender meat.",
            'rock crab': "which has a robust shell and is found in rocky areas.",
            'fiddler crab': "which has one oversized claw and lives in burrows.",
            'red king crab': "which has long legs and is prized for its meat.",
            'American lobster': "which has large claws and a long, muscular body.",
            'spiny lobster': "which has long antennae and lacks large claws.",
            'crayfish': "which has a similar appearance to small lobsters.",
            'hermit crab': "which carries its home in a discarded shell.",
            'isopod': "which has a segmented body and can be aquatic or terrestrial.",
            'white stork': "which has long legs and a distinctive black and white plumage.",
            'black stork': "which has dark feathers and a slender neck.",
            'spoonbill': "which has a long, flat bill shaped like a spoon.",
            'flamingo': "which has long legs and pink feathers due to diet.",
            'little blue heron': "which has a slender body and striking blue-gray plumage.",
            'great egret': "which has long legs and a graceful white body.",
            'bittern bird': "which has a stout body and blends well in reeds.",
            'crane bird': "which has long legs and a graceful, upright stance.",
            'limpkin': "which has a long bill and a distinctive, haunting call.",
            'common gallinule': "which has a rounded body and bright red frontal shield.",
            'American coot': "which has a black body and a white bill.",
            'bustard': "which has a large body and impressive courtship displays.",
            'ruddy turnstone': "which has a small body and a distinctive bill.",
            'dunlin': "which has a slender body and short legs with a curved bill.",
            'common redshank': "which has a long leg and reddish-brown plumage.",
            'dowitcher': "which has a long bill and is known for probing mud.",
            'oystercatcher': "which has a long bill for prying open shellfish.",
            'pelican': "which has a large bill with a throat pouch.",
            'king penguin': "which has a colorful orange and yellow neck patch.",
            'albatross': "which has long wings and is known for its gliding flight.",
            'grey whale': "which has a massive body and migrates long distances.",
            'killer whale': "which has distinctive black and white markings.",
            'dugong': "which has a large, rounded body and is herbivorous.",
            'sea lion': "which has external ear flaps and can walk on land.",
            'Chihuahua': "which has a small size and large, expressive eyes.",
            'Japanese Chin': "which has long, flowing hair and a charming demeanor.",
            'Maltese': "which has a long, silky white coat and friendly nature.",
            'Pekingese': "which has a flat face and long fur, resembling a lion.",
            'Shih Tzu': "which has a long coat and a friendly disposition.",
            'King Charles Spaniel': "which has large, dark eyes and a gentle nature.",
            'Papillon': "which has large, butterfly-like ears and a lively personality.",
            'toy terrier': "which is small, energetic, and has a playful temperament.",
            'Rhodesian Ridgeback': "which has a distinctive ridge of hair along its back.",
            'Afghan Hound': "which has long, flowing hair and a graceful appearance.",
            'Basset Hound': "which has long ears and a distinctive droopy face.",
            'Beagle': "which has a keen sense of smell and friendly demeanor.",
            'Bloodhound': "which has an incredible sense of smell and droopy ears.",
            'Bluetick Coonhound': "which has a mottled coat and excels in hunting.",
            'Black and Tan Coonhound': "which has a sleek black coat with tan markings.",
            'Treeing Walker Coonhound': "which has a tall, athletic build and long legs.",
            'English foxhound': "which has a sturdy body and is used in hunting.",
            'Redbone Coonhound': "which has a sleek, red coat and is great at tracking.",
            'borzoi': "which has a long, narrow head and a graceful build.",
            'Irish Wolfhound': "which has a massive frame and is very gentle.",
            'Italian Greyhound': "which has a slender build and short, fine coat.",
            'Whippet': "which is slender and known for its speed and agility.",
            'Ibizan Hound': "which has large ears and a sleek, athletic body.",
            'Norwegian Elkhound': "which has a thick coat and is used for hunting.",
            'Otterhound': "which has a waterproof coat and webbed feet.",
            'Saluki': "which has a slim build and is known for its speed.",
            'Scottish Deerhound': "which has a tall, dignified presence and shaggy coat.",
            'Weimaraner': "which has a sleek gray coat and is highly trainable.",
            'Staffordshire Bull Terrier': "which has a muscular build and a friendly demeanor.",
            'American Staffordshire Terrier': "which is strong, loyal, and often misunderstood.",
            'Bedlington Terrier': "which has a distinctive lamb-like appearance and curly coat.",
            'Border Terrier': "which is small with a wiry coat and lively personality.",
            'Kerry Blue Terrier': "which has a soft, curly coat and is intelligent.",
            'Irish Terrier': "which has a dense, wiry coat and is courageous.",
            'Norfolk Terrier': "which is small and known for its playful nature.",
            'Norwich Terrier': "which has a rough coat and a lively disposition.",
            'Yorkshire Terrier': "which is small with long, silky hair and spunky.",
            'Wire Fox Terrier': "which has a wiry coat and is energetic and playful.",
            'Lakeland Terrier': "which has a distinctive face and a spirited personality.",
            'Sealyham Terrier': "which is small with a long body and cheerful nature.",
            'Airedale Terrier': "which is the largest of terriers, with a long snout.",
            'Cairn Terrier': "which has a shaggy coat and is known for its tenacity.",
            'Australian Terrier': "which has a rough coat and is energetic and alert.",
            'Dandie Dinmont Terrier': "which has a distinctive topknot of hair and friendly demeanor.",
            'Boston Terrier': "which has a tuxedo-like coat and friendly disposition.",
            'Miniature Schnauzer': "which has a bushy beard and a spirited personality.",
            'Giant Schnauzer': "which is strong and often used as a working dog.",
            'Standard Schnauzer': "which has a wiry coat and a friendly temperament.",
            'Scottish Terrier': "which has a distinctive beard and is independent-minded.",
            'Tibetan Terrier': "which has a long, thick coat and friendly disposition.",
            'Australian Silky Terrier': "which has a long, silky coat and is lively.",
            'Soft-coated Wheaten Terrier': "which has a soft, silky coat and cheerful demeanor.",
            'West Highland White Terrier': "which has a fluffy white coat and is playful.",
            'Lhasa Apso': "which has a long coat and a cheerful disposition.",
            'Flat-Coated Retriever': "which has a glossy black or liver-colored coat.",
            'Curly-coated Retriever': "which has a dense, curly coat and is energetic.",
            'Golden Retriever': "which is friendly, intelligent, and has a golden coat.",
            'Labrador Retriever': "which is friendly and is known for its retrieving skills.",
            'Chesapeake Bay Retriever': "which has a water-resistant coat and strong build.",
            'German Shorthaired Pointer': "which has a sleek, spotted coat and hunting skills.",
            'Vizsla': "which has a short, rust-colored coat and is affectionate.",
            'English Setter': "which has long, feathered hair and is known for hunting.",
            'Irish Setter': "which has a striking red coat and is friendly.",
            'Gordon Setter': "which has a long, flowing coat and a regal appearance.",
            'Brittany dog': "which has a dense, wavy coat and is energetic.",
            'Clumber Spaniel': "which has a heavy build and a sweet nature.",
            'English Springer Spaniel': "which has a sturdy build and friendly personality.",
            'Welsh Springer Spaniel': "which has a longer coat and energetic disposition.",
            'Cocker Spaniel': "which has long ears and a friendly demeanor.",
            'Sussex Spaniel': "which has a distinctively thick, golden coat.",
            'Irish Water Spaniel': "which has a curly coat and enjoys water.",
            'Kuvasz': "which has a thick white coat and is protective.",
            'Schipperke': "which is small with a fox-like face and lively personality.",
            'Groenendael dog': "which has a long, black coat and is intelligent.",
            'Malinois': "which is a versatile working dog with a short coat.",
            'Briard': "which has a long, shaggy coat and herding instincts.",
            'Australian Kelpie': "which has a keen sense and is great for herding.",
            'Komondor': "which has a distinctive corded coat and is protective.",
            'Old English Sheepdog': "which has a shaggy coat and is gentle.",
            'Shetland Sheepdog': "which has a long, thick coat and is intelligent.",
            'collie': "which has a long coat and is known for herding.",
            'Border Collie': "which has a high energy level and is intelligent.",
            'Bouvier des Flandres dog': "which has a thick coat and is a working dog.",
            'Rottweiler': "which has a strong build and protective nature.",
            'German Shepherd Dog': "which is intelligent and highly trainable.",
            'Dobermann': "which is sleek and known for its loyalty and courage.",
            'Miniature Pinscher': "which is small, energetic, and has a sleek coat.",
            'Greater Swiss Mountain Dog': "which has a strong build and is friendly.",
            'Bernese Mountain Dog': "which has a long, thick coat and is gentle.",
            'Appenzeller Sennenhund': "which has a thick coat and is a herding dog.",
            'Entlebucher Sennenhund': "which has a stocky build and is playful.",
            'Boxer': "which has a strong build and is energetic.",
            'Bullmastiff': "which is large, powerful, and protective.",
            'Tibetan Mastiff': "which is large with a thick fur coat and protective.",
            'French Bulldog': "which is small with a flat face and bat-like ears.",
            'Great Dane': "which is very large and friendly with a majestic appearance.",
            'St. Bernard': "which is large and known for its rescue work.",
            'husky': "which has a thick coat and is known for endurance.",
            'Alaskan Malamute': "which has a strong build and is great for pulling.",
            'Siberian Husky': "which has striking blue or multi-colored eyes.",
            'Dalmatian': "which has a distinctive spotted coat and is energetic.",
            'Affenpinscher': "which is small with a monkey-like face and playful.",
            'Basenji': "which is small and known for its yodel-like bark.",
            'pug': "which has a wrinkled face and charming personality.",
            'Leonberger': "which is large with a gentle and friendly demeanor.",
            'Newfoundland dog': "which is large with a water-resistant coat and gentle.",
            'Great Pyrenees dog': "which has a thick white coat and is protective.",
            'Samoyed': "which has a fluffy white coat and a friendly smile.",
            'Pomeranian': "which is small and has a thick, fluffy coat.",
            'Chow Chow': "which has a thick mane and a blue-black tongue.",
            'Keeshond': "which has a distinctive facial markings and fluffy coat.",
            'brussels griffon': "which has a short snout and lively personality.",
            'Pembroke Welsh Corgi': "which has short legs and a distinctive body.",
            'Cardigan Welsh Corgi': "which has a long tail and a sturdy build.",
            'Toy Poodle': "which is small, intelligent, and curly-haired.",
            'Miniature Poodle': "which has a curly coat and is highly trainable.",
            'Standard Poodle': "which has a curly coat and is intelligent.",
            'Mexican hairless dog (xoloitzcuintli)': "which has no hair and is known for warmth.",
            'grey wolf': "which has a thick coat and lives in packs.",
            'Alaskan tundra wolf': "which has a thick, warm coat and is majestic.",
            'red wolf or maned wolf': "which has a slender build and reddish fur.",
            'coyote': "which has a slender build and bushy tail.",
            'dingo': "which is a wild dog native to Australia.",
            'dhole': "which has a slender body and hunts in packs.",
            'African wild dog': "which has a mottled coat and hunts in packs.",
            'hyena': "which has a strong build and is known for scavenging.",
            'red fox': "which has a bushy tail and is known for cunning.",
            'kit fox': "which is small with large ears and agile.",
            'Arctic fox': "which has a thick coat that changes color in winter.",
            'grey fox': "which has a bushy tail and is adaptable.",
            'tabby cat': "which has a patterned coat with stripes or spots.",
            'tiger cat': "which has a striped coat and is small.",
            'Persian cat': "which has a long, fluffy coat and sweet disposition.",
            'Siamese cat': "which has striking blue eyes and a short coat.",
            'Egyptian Mau': "which has a spotted coat and striking green eyes.",
            'cougar': "which has a powerful build and is solitary.",
            'lynx': "which has tufted ears and a short tail.",
            'leopard': "which has a spotted coat and is known for strength.",
            'snow leopard': "which has a thick coat and long tail for balance.",
            'jaguar': "which has a robust body and large rosettes on its coat.",
            'lion': "which has a majestic mane and is known as king of beasts.",
            'tiger': "which has bold stripes and is a powerful predator.",
            'cheetah': "which is known for its speed and slender body.",
            'brown bear': "which has a stocky build and thick fur.",
            'American black bear': "which has a rounded face and black fur.",
            'polar bear': "which has thick white fur and is found in cold areas.",
            'sloth bear': "which has long claws and a shaggy coat.",
            'mongoose': "which has a slender body and is known for agility.",
            'meerkat': "which is small, social, and stands on hind legs.",
            'tiger beetle': "which has a shiny body and swift movement.",
            'ladybug': "which has a round body and spots, often red.",
            'ground beetle': "which has a hard shell and fast-moving legs.",
            'longhorn beetle': "which has long antennae and a sturdy body.",
            'leaf beetle': "which has a flattened body and colorful patterns.",
            'dung beetle': "which rolls dung and has a hard shell.",
            'rhinoceros beetle': "which has a distinctive horn and strong build.",
            'weevil': "which has a long snout and is often found in grains.",
            'fly': "which has wings and is often a nuisance.",
            'bee': "which is known for pollination and making honey.",
            'ant': "which is social and often found in colonies.",
            'grasshopper': "which has long hind legs for jumping.",
            'cricket insect': "which chirps and has long antennae.",
            'stick insect': "which mimics twigs and branches for camouflage.",
            'cockroach': "which is known for its resilience and fast movement.",
            'praying mantis': "which has a distinctive posture and predatory habits.",
            'cicada': "which has a loud call and life cycle underground.",
            'leafhopper': "which has a small body and jumps quickly.",
            'lacewing': "which has delicate wings and is beneficial for gardens.",
            'dragonfly': "which has large, multifaceted eyes and is agile.",
            'damselfly': "which is similar to a dragonfly but smaller and slimmer.",
            'red admiral butterfly': "which has black wings with striking orange-red bands.",
            'ringlet butterfly': "which has brown wings with circular eye spots.",
            'monarch butterfly': "which is known for its orange and black wing pattern.",
            'small white butterfly': "which has white wings and is commonly found.",
            'sulphur butterfly': "which has yellow wings and is commonly seen.",
            'gossamer-winged butterfly': "which has delicate wings and iridescent colors.",
            'starfish': "which has five arms and lives in marine environments.",
            'sea urchin': "which has spiny armor and is found in oceans.",
            'sea cucumber': "which is elongated and has a leathery skin.",
            'cottontail rabbit': "which has a fluffy tail and is common in gardens.",
            'hare': "which is larger than a rabbit and has long ears.",
            'Angora rabbit': "which has long, soft fur and is often kept as a pet.",
            'hamster': "which is small, nocturnal, and popular as a pet.",
            'porcupine': "which has quills for defense and a stout body.",
            'fox squirrel': "which has a bushy tail and is common in parks.",
            'marmot': "which is large and known for living in colonies.",
            'beaver': "which has a flat tail and builds dams in rivers.",
            'guinea pig': "which is small and social, often kept as a pet.",
            'common sorrel horse': "which is a common breed known for its athleticism.",
            'zebra': "which has distinctive black and white stripes.",
            'pig': "which is pink or black and known for intelligence.",
            'wild boar': "which has tusks and a shaggy coat.",
            'warthog': "which has large tusks and a rugged appearance.",
            'hippopotamus': "which is large and semi-aquatic with a big mouth.",
            'ox': "which is a large bovine often used for farming.",
            'water buffalo': "which is large and known for its strength in agriculture.",
            'bison': "which is large and has a thick coat for insulation.",
            'ram (adult male sheep)': "which has large curved horns and a strong build.",
            'bighorn sheep': "which has large, curved horns and lives in mountainous areas.",
            'Alpine ibex': "which has long, curved horns and is agile.",
            'hartebeest': "which has a slender body and long legs for speed.",
            'impala (antelope)': "which has a sleek body and is known for jumping.",
            'gazelle': "which has a slender body and is agile and fast.",
            'arabian camel': "which has one hump and is adapted for deserts.",
            'llama': "which is domesticated and known for carrying loads.",
            'weasel': "which is small and has a long, slender body.",
            'mink': "which has a luxurious fur coat and is agile.",
            'European polecat': "which has a long body and is known for being elusive.",
            'black-footed ferret': "which has a black mask and is endangered.",
            'otter': "which is aquatic, playful, and has a thick coat.",
            'skunk': "which has a distinctive smell and is known for its stripes.",
            'badger': "which has a stout body and burrows underground.",
            'armadillo': "which has a hard shell and rolls into a ball.",
            'three-toed sloth': "which moves slowly and lives in trees.",
            'orangutan': "which has long arms and lives in trees.",
            'gorilla': "which is large, powerful, and lives in groups.",
            'chimpanzee': "which is intelligent and known for using tools.",
            'gibbon': "which has long arms and swings through trees.",
            'siamang': "which has a larger body and is known for vocalizing.",
            'guenon': "which is colorful and has a long tail.",
            'patas monkey': "which is agile and known for running quickly.",
            'baboon': "which is social and known for its large canine teeth.",
            'macaque': "which has a strong build and lives in troops.",
            'langur': "which is slender and has long limbs for climbing.",
            'black-and-white colobus': "which has a distinctive coat and lives in trees.",
            'proboscis monkey': "which has a large nose and is known for vocalizing.",
            'marmoset': "which is small and often keeps a close-knit group.",
            'white-headed capuchin': "which is intelligent and known for using tools.",
            'howler monkey': "which has a loud call and lives in trees.",
            'titi monkey': "which is small and has a long tail.",
            "Geoffroy's spider monkey": "which is agile and known for hanging from trees.",
            'common squirrel monkey': "which is small and very social.",
            'ring-tailed lemur': "which has a long tail with rings and is social.",
            'indri': "which is the largest living lemur and has loud calls.",
            'Asian elephant': "which is smaller than African elephants and has smaller ears.",
            'African bush elephant': "which is the largest land animal with large ears.",
            'red panda': "which is small, has reddish-brown fur, and is arboreal.",
            'giant panda': "which is black and white and known for eating bamboo.",
            'snoek fish': "which is long and slender, often found in cold waters.",
            'eel': "which has a long, snake-like body and is slippery.",
            'silver salmon': "which is known for its pinkish color and taste.",
            'rock beauty fish': "which has striking colors and patterns.",
            'clownfish': "which is bright orange with white stripes and lives in anemones.",
            'sturgeon': "which is large and known for its roe or caviar.",
            'gar fish': "which has a long, slender body and bony structure.",
            'lionfish': "which has long, venomous spines and striking colors.",
            'pufferfish': "which can inflate itself and has spines for defense.",
            'abacus': "which is a counting tool with beads on rods.",
            'abaya': "which is a long, flowing robe worn by women.",
            'academic gown': "which is worn during graduation ceremonies.",
            'accordion': "which is a musical instrument with a bellows and keys.",
            'acoustic guitar': "which is a stringed instrument that produces sound acoustically.",
            'aircraft carrier': "which is a large naval ship designed for aircraft operations.",
            'airliner': "which is a large passenger airplane used for commercial flights.",
            'airship': "which is a dirigible that is filled with gas for lift.",
            'altar': "which is a table used for religious rituals.",
            'ambulance': "which is a vehicle designed for emergency medical services.",
            'amphibious vehicle': "which can operate on land and water.",
            'analog clock': "which displays time with hands on a dial.",
            'apiary': "which is a place where beehives are kept.",
            'apron': "which is worn to protect clothes while cooking.",
            'trash can': "which is used for waste disposal.",
            'assault rifle': "which is a rapid-fire, military-grade firearm.",
            'backpack': "which is a bag carried on the back.",
            'bakery': "which is a shop where bread and pastries are made.",
            'balance beam': "which is a narrow platform used in gymnastics.",
            'balloon': "which is an inflatable object used for decoration.",
            'ballpoint pen': "which is a writing instrument with a retractable ball.",
            'Band-Aid': "which is a small adhesive bandage for minor wounds.",
            'banjo': "which is a stringed instrument with a circular body.",
            'baluster / handrail': "which is a post supporting a staircase railing.",
            'barbell': "which is used in weightlifting for strength training.",
            'barber chair': "which is designed for use in barbershops.",
            'barbershop': "which has hair cutting tools and styling stations.",
            'barn': "which has a large wooden structure for livestock storage.",
            'barometer': "which has a glass tube measuring atmospheric pressure.",
            'barrel': "which has a cylindrical wooden container for storage.",
            'wheelbarrow': "which has a single wheel and handles for transport.",
            'baseball': "which has a leather cover and cork core for sports.",
            'basketball': "which has an orange rubber surface for bouncing play.",
            'bassinet': "which has a small cradle for newborns to sleep.",
            'bassoon': "which has a long wooden body and double reed mouthpiece.",
            'swimming cap': "which has a tight-fitting design for hair protection.",
            'bath towel': "which has a soft, absorbent fabric for drying off.",
            'bathtub': "which has a large basin for bathing in water.",
            'station wagon': "which has extended cargo space for family travel.",
            'lighthouse': "which has a tall tower guiding ships at sea.",
            'beaker': "which has a graduated container for measuring liquids.",
            'military hat (bearskin or shako)': "which has a tall, decorative headpiece for soldiers.",
            'beer bottle': "which has a glass container for storing beer.",
            'beer glass': "which has a wide rim for drinking beer comfortably.",
            'bell tower': "which has a tall structure housing a ringing bell.",
            'baby bib': "which has a cloth cover to protect infants during feeding.",
            'tandem bicycle': "which has two seats and two sets of pedals.",
            'bikini': "which has a two-piece swimsuit for beach wear.",
            'ring binder': "which has metal rings for holding punched paper sheets.",
            'binoculars': "which has lenses for magnifying distant objects.",
            'birdhouse': "which has a small shelter for birds to nest.",
            'boathouse': "which has a structure for storing boats on water.",
            'bobsleigh': "which has a sled for racing down snowy tracks.",
            'bolo tie': "which has a necktie with a decorative sliding clasp.",
            'poke bonnet': "which has a wide-brimmed hat for sun protection.",
            'bookcase': "which has shelves for storing books and literature.",
            'bookstore': "which has a retail space selling various books.",
            'bottle cap': "which has a circular closure for sealing bottles.",
            'hunting bow': "which has a flexible weapon for shooting arrows.",
            'bow tie': "which has a formal necktie with a bow shape.",
            'brass memorial plaque': "which has engraved metal for commemorating individuals.",
            'bra': "which has a supportive undergarment for women’s bust.",
            'breakwater': "which has a structure protecting harbors from waves.",
            'breastplate': "which has armor covering the front torso in battle.",
            'broom': "which has a long handle and bristles for sweeping.",
            'bucket': "which has a container for carrying liquids or materials.",
            'buckle': "which has a clasp for fastening belts or straps.",
            'bulletproof vest': "which has protective clothing to resist bullets.",
            'high-speed train': "which has aerodynamic design for rapid land travel.",
            'butcher shop': "which has a retail space selling meat products.",
            'taxicab': "which has a vehicle for hired passenger transportation.",
            'cauldron': "which has a large pot for cooking over fire.",
            'candle': "which has wax for illumination when burned.",
            'cannon': "which has a large gun for firing projectiles.",
            'canoe': "which has a narrow boat powered by paddles.",
            'can opener': "which has a tool for opening metal cans.",
            'cardigan': "which has a knitted sweater with an open front.",
            'car mirror': "which has a reflective surface for viewing surroundings.",
            'carousel': "which has a rotating platform with seats for amusement.",
            'tool kit': "which has a collection of various tools for repair.",
            'cardboard box / carton': "which has a container made from cardboard material.",
            'car wheel': "which has a round component enabling vehicle movement.",
            'automated teller machine': "which has a machine for withdrawing cash electronically.",
            'cassette': "which has a magnetic tape for audio recording.",
            'cassette player': "which has a device for playing cassette tapes.",
            'castle': "which has a fortified residence for nobility or royalty.",
            'catamaran': "which has a twin-hulled boat for stability on water.",
            'CD player': "which has a device for playing compact discs.",
            'cello': "which has a large string instrument played with a bow.",
            'mobile phone': "which has a handheld device for communication.",
            'chain': "which has linked metal rings for securing objects.",
            'chain-link fence': "which has interwoven metal links for property enclosure.",
            'chain mail': "which has a protective armor made of interlinked metal.",
            'chainsaw': "which has a power tool for cutting wood quickly.",
            'storage chest': "which has a box for organizing and storing items.",
            'chiffonier': "which has a tall chest of drawers for clothing.",
            'bell or wind chime': "which has a decorative object producing sound in wind.",
            'china cabinet': "which has a glass-fronted display for dishes and glassware.",
            'Christmas stocking': "which has a festive bag for holiday gifts.",
            'church': "which has a building for Christian worship and community.",
            'movie theater': "which has a venue for screening films to audiences.",
            'cleaver': "which has a heavy knife for chopping meat.",
            'cliff dwelling': "which has a residence built into a rock face.",
            'cloak': "which has a loose outer garment for warmth.",
            'clogs': "which has wooden shoes with a closed toe.",
            'cocktail shaker': "which has a container for mixing drinks.",
            'coffee mug': "which has a large cup for hot beverages.",
            'coffeemaker': "which has an appliance for brewing coffee.",
            'spiral or coil': "which has a twisted shape resembling a helix.",
            'combination lock': "which has a lock opened with a rotating dial.",
            'computer keyboard': "which has keys for inputting data into computers.",
            'candy store': "which has a retail shop selling sweets and chocolates.",
            'container ship': "which has a large vessel for transporting cargo.",
            'convertible': "which has a car with a retractable roof.",
            'corkscrew': "which has a tool for removing corks from bottles.",
            'cornet': "which has a brass musical instrument with a bell.",
            'cowboy boot': "which has high-heeled footwear with a pointed toe.",
            'cowboy hat': "which has a wide-brimmed hat for sun protection.",
            'cradle': "which has a small bed for infants to sleep.",
            'construction crane': "which has a machine for lifting heavy materials.",
            'crash helmet': "which has a protective headgear for safety.",
            'crate': "which has a wooden container for transporting goods.",
            'infant bed': "which has a small bed designed for babies.",
            'Crock Pot': "which has a slow cooker for preparing meals.",
            'croquet ball': "which has a ball used in the croquet game.",
            'crutch': "which has a support for assisting injured legs.",
            'cuirass': "which has armor protecting the torso in battle.",
            'dam': "which has a barrier for holding back water.",
            'desk': "which has a surface for working or studying.",
            'desktop computer': "which has a stationary computer setup for use.",
            'rotary dial telephone': "which has a phone with a rotating dial for numbers.",
            'diaper': "which has a cloth or disposable covering for infants.",
            'digital clock': "which has an electronic display for showing time.",
            'digital watch': "which has a wristwatch displaying time digitally.",
            'dining table': "which has a table for meals and gatherings.",
            'dishcloth': "which has a cloth for washing dishes and utensils.",
            'dishwasher': "which has a machine for automatically cleaning dishes.",
            'disc brake': "which has a braking system using friction discs.",
            'dock': "which has a platform for loading and unloading boats.",
            'dog sled': "which has a vehicle pulled by dogs over snow.",
            'dome': "which has a rounded architectural roof structure.",
            'doormat': "which has a mat placed at entrances to wipe feet.",
            'drilling rig': "which has equipment for drilling holes in the ground.",
            'drum': "which has a percussion instrument played with sticks.",
            'drumstick': "which has a stick used for playing drums.",
            'dumbbell': "which has a weight for strength training exercises.",
            'Dutch oven': "which has a heavy pot for cooking over heat.",
            'electric fan': "which has a device for circulating air.",
            'electric guitar': "which has a guitar amplified by electrical pickups.",
            'electric locomotive': "which has a train powered by electric motors.",
            'entertainment center': "which has a unit for housing electronics and media.",
            'envelope': "which has a folded paper for enclosing letters.",
            'espresso machine': "which has a device for brewing espresso coffee.",
            'face powder': "which has a cosmetic for setting makeup.",
            'feather boa': "which has a decorative scarf made of feathers.",
            'filing cabinet': "which has drawers for organizing paper documents.",
            'fireboat': "which has a vessel designed for firefighting on water.",
            'fire truck': "which has a vehicle equipped for firefighting emergencies.",
            'fire screen': "which has a protective barrier in front of a fire.",
            'flagpole': "which has a tall post for displaying flags.",
            'flute': "which has a woodwind instrument played by blowing air.",
            'folding chair': "which has a chair that can be collapsed for storage.",
            'football helmet': "which has protective gear worn by players in football.",
            'forklift': "which has a powered vehicle for lifting heavy loads.",
            'fountain': "which has a decorative water feature in gardens.",
            'fountain pen': "which has a pen using liquid ink for writing.",
            'four-poster bed': "which has a bed with four vertical posts.",
            'freight car': "which has a railway car for transporting goods.",
            'French horn': "which has a brass instrument with a coiled shape.",
            'frying pan': "which has a flat pan for cooking food over heat.",
            'fur coat': "which has a garment made from animal fur for warmth.",
            'garbage truck': "which has a vehicle for collecting waste materials.",
            'gas mask or respirator': "which has a protective mask for filtering air.",
            'gas pump': "which has a device for dispensing fuel into vehicles.",
            'goblet': "which has a decorative cup for drinking beverages.",
            'go-kart': "which has a small racing vehicle with four wheels.",
            'golf ball': "which has a small ball used in the sport of golf.",
            'golf cart': "which has a small vehicle for transporting golfers.",
            'gondola': "which has a boat used for travel on canals.",
            'gong': "which has a metal disc that produces a deep sound.",
            'gown': "which has a long dress for formal occasions.",
            'grand piano': "which has a large musical instrument for playing music.",
            'greenhouse': "which has a structure for growing plants in controlled conditions.",
            'radiator grille': "which has a front cover for vehicle cooling systems.",
            'grocery store': "which has a retail shop for selling food and supplies.",
            'guillotine': "which has a device for executing with a sharp blade.",
            'hair clip': "which has a tool for fastening hair in place.",
            'hair spray': "which has a cosmetic for styling hair.",
            'half-track': "which has a vehicle with wheels and continuous tracks.",
            'hammer': "which has a tool for driving nails into surfaces.",
            'hamper': "which has a basket for storing laundry or goods.",
            'hair dryer': "which has a device for blowing hot air to dry hair.",
            'hand-held computer': "which has a portable device for computing tasks.",
            'handkerchief': "which has a piece of cloth for wiping hands or face.",
            'hard disk drive': "which has a device for storing digital data.",
            'harmonica': "which has a small wind instrument played by blowing.",
            'harp': "which has a large string instrument played by plucking.",
            'combine harvester': "which has a machine for harvesting crops efficiently.",
            'hatchet': "which has a small axe for chopping wood.",
            'holster': "which has a case for carrying a firearm.",
            'home theater': "which has a setup for watching movies at home.",
            'honeycomb': "which has a structure made by bees for storing honey.",
            'hook': "which has a curved object for catching or holding.",
            'hoop skirt': "which has a crinoline petticoat for a fuller dress shape.",
            'gymnastic horizontal bar': "which has a bar for performing gymnastic routines.",
            'horse-drawn vehicle': "which has a carriage pulled by horses.",
            'hourglass': "which has a device measuring time with sand.",
            'iPod': "which has a portable media player for music and audio.",
            'clothes iron': "which has a device for pressing clothes flat.",
            'carved pumpkin': "which has a pumpkin cut into a decorative design.",
            'jeans': "which has denim pants for casual wear.",
            'jeep': "which has a rugged vehicle for off-road driving.",
            'T-shirt': "which has a casual shirt with short sleeves.",
            'jigsaw puzzle': "which has a game made of interlocking pieces.",
            'rickshaw': "which has a two-wheeled vehicle for human transport.",
            'joystick': "which has a control device for gaming and navigation.",
            'kimono': "which has a traditional Japanese robe with wide sleeves.",
            'knee pad': "which has protective gear for covering the knees.",
            'knot': "which has a fastening made by tying a rope.",
            'lab coat': "which has a white coat worn for scientific work.",
            'ladle': "which has a large spoon for serving liquids.",
            'lampshade': "which has a cover for diffusing light from lamps.",
            'laptop computer': "which has a portable personal computer with a screen.",
            'lawn mower': "which has a machine for cutting grass in yards.",
            'lens cap': "which has a cover for protecting camera lenses.",
            'letter opener': "which has a tool for opening envelopes.",
            'library': "which has a building for housing books and resources.",
            'lifeboat': "which has a small boat for emergency water rescues.",
            'lighter': "which has a device for igniting flames.",
            'limousine': "which has a luxury vehicle for transporting passengers.",
            'ocean liner': "which has a large ship for ocean travel.",
            'lipstick': "which has a cosmetic for coloring and beautifying lips.",
            'slip-on shoe': "which has a shoe designed for easy wear.",
            'lotion': "which has a liquid for moisturizing skin.",
            'music speaker': "which has a device for amplifying audio sounds.",
            'loupe magnifying glass': "which has a small lens for magnifying objects.",
            'sawmill': "which has a facility for cutting wood into lumber.",
            'magnetic compass': "which has a tool for determining direction.",
            'messenger bag': "which has a shoulder bag for carrying items.",
            'mailbox': "which has a container for receiving postal mail.",
            'tights': "which has fitted legwear for warmth or fashion.",
            'one-piece bathing suit': "which has a single garment for swimming.",
            'manhole cover': "which has a heavy lid for covering underground access.",
            'maraca': "which has a percussion instrument filled with beads.",
            'marimba': "which has a musical instrument with wooden bars.",
            'mask': "which has a covering for the face for disguise.",
            'matchstick': "which has a thin stick used for striking fire.",
            'maypole': "which has a tall pole decorated for May Day celebrations.",
            'maze': "which has a complex pathway for navigation challenges.",
            'measuring cup': "which has a container for measuring ingredients.",
            'medicine cabinet': "which has a storage unit for medical supplies.",
            'megalith': "which has a large stone structure from ancient times.",
            'microphone': "which has a device for amplifying sound.",
            'microwave oven': "which has a kitchen appliance for quickly heating food.",
            'military uniform': "which has a standard clothing worn by armed forces.",
            'milk can': "which has a container for storing and transporting milk.",
            'minibus': "which has a smaller bus for group transportation.",
            'miniskirt': "which has a short skirt above the knee.",
            'minivan': "which has a family-friendly vehicle with sliding doors.",
            'missile': "which has a projectile weapon designed for targeted attacks.",
            'mitten': "which has handwear with a single compartment for fingers.",
            'mixing bowl': "which has a bowl for combining ingredients.",
            'mobile home': "which has a transportable dwelling for living.",
            'ford model t': "which has a historic car model from the early 20th century.",
            'modem': "which has a device for connecting to the internet.",
            'monastery': "which has a residence for monks or religious communities.",
            'monitor': "which has a screen for displaying computer output.",
            'moped': "which has a small motorized bicycle for transport.",
            'mortar and pestle': "which has a tool for grinding substances.",
            'graduation cap': "which has a flat hat worn during graduation ceremonies.",
            'mosque': "which has a place of worship in Islam.",
            'mosquito net': "which has a mesh covering to protect against insects.",
            'vespa': "which has a small scooter for urban commuting.",
            'mountain bike': "which has a bicycle designed for off-road terrain.",
            'tent': "which has a portable shelter for camping outdoors.",
            'computer mouse': "which has a device for pointing and clicking.",
            'mousetrap': "which has a device for capturing mice.",
            'moving van': "which has a vehicle for transporting furniture.",
            'muzzle': "which has a covering for an animal's snout.",
            'metal nail': "which has a small metal spike used in construction.",
            'neck brace': "which has a device for supporting the neck.",
            'necklace': "which has a piece of jewelry worn around the neck.",
            'baby pacifier': "which has a rubber nipple for soothing infants.",
            'notebook computer': "which has a portable computer for writing and tasks.",
            'obelisk': "which has a tall stone pillar, often commemorative.",
            'oboe': "which has a woodwind instrument with a double reed.",
            'ocarina': "which has an ancient wind instrument with holes.",
            'odometer': "which has a device measuring distance traveled by a vehicle.",
            'oil filter': "which has a device for removing impurities from oil.",
            'pipe organ': "which has a musical instrument using air through pipes.",
            'oscilloscope': "which has a device for visualizing electronic signals.",
            'overskirt': "which has a skirt worn over another garment.",
            'bullock cart': "which has a cart pulled by oxen.",
            'oxygen mask': "which has a device for supplying oxygen to users.",
            'product packet / packaging': "which has a container for food or products.",
            'paddle': "which has a tool for propelling a boat.",
            'paddle wheel': "which has a wheel with paddles for moving watercraft.",
            'padlock': "which has a lock that can be secured with a key.",
            'paintbrush': "which has a tool for applying paint.",
            'pajamas': "which has a set of loose clothing for sleeping.",
            'palace': "which has a large building for royal residence.",
            'pan flute': "which has a musical instrument made of tuned pipes.",
            'paper towel': "which has absorbent sheets for cleaning spills.",
            'parachute': "which has a device used for descending safely from heights.",
            'parallel bars': "which has equipment for gymnastic routines.",
            'park bench': "which has a seat in a public park for resting.",
            'parking meter': "which has a device for collecting parking fees.",
            'railroad car': "which has a vehicle for transporting goods by rail.",
            'patio': "which has an outdoor space for dining or relaxation.",
            'payphone': "which has a public telephone requiring payment.",
            'pedestal': "which has a base for supporting a statue or column.",
            'pencil case': "which has a container for storing writing instruments.",
            'pencil sharpener': "which has a device for sharpening pencils.",
            'perfume': "which has a fragrant liquid for personal scent.",
            'Petri dish': "which has a shallow dish for growing cultures.",
            'photocopier': "which has a machine for duplicating documents.",
            'plectrum': "which has a small tool for plucking musical strings.",
            'Pickelhaube': "which has a spiked helmet worn by German soldiers.",
            'picket fence': "which has a low fence made of wooden stakes.",
            'pickup truck': "which has a vehicle with an open cargo area.",
            'pier': "which has a structure extending into a body of water.",
            'piggy bank': "which has a container for saving coins.",
            'pill bottle': "which has a container for storing medication.",
            'pillow': "which has a cushion for supporting the head during sleep.",
            'ping-pong ball': "which has a small ball used in table tennis.",
            'pinwheel': "which has a toy that spins in the wind.",
            'pirate ship': "which has a vessel associated with piracy on the seas.",
            'drink pitcher': "which has a container for pouring beverages.",
            'block plane': "which has a tool for smoothing wood surfaces.",
            'planetarium': "which has a facility for projecting stars and planets.",
            'plastic bag': "which has a flexible container made from plastic.",
            'plate rack': "which has a holder for displaying or drying plates.",
            'farm plow': "which has a tool for tilling soil in agriculture.",
            'plunger': "which has a tool for unclogging drains.",
            'Polaroid camera': "which has a camera that prints instant photos.",
            'pole': "which has a long, slender object or support.",
            'police van': "which has a vehicle for transporting police officers.",
            'poncho': "which has a waterproof garment worn over the body.",
            'pool table': "which has a table for playing billiards or pool.",
            'soda bottle': "which has a container for carbonated beverages.",
            'plant pot': "which has a container for growing plants.",
            "potter's wheel": "which has a machine for shaping clay into pottery.",
            'power drill': "which has a tool for drilling holes into materials.",
            'prayer rug': "which has a mat used for Islamic prayers.",
            'printer': "which has a device for producing printed documents.",
            'prison': "which has a facility for incarcerating individuals.",
            'projector': "which has a device for displaying images on a screen.",
            'hockey puck': "which has a disc used in the game of hockey.",
            'punching bag': "which has a bag used for practicing punches.",
            'purse': "which has a small bag for carrying personal items.",
            'quill': "which has a writing tool made from a feather.",
            'quilt': "which has a layered blanket made of fabric.",
            'race car': "which has a high-speed vehicle designed for racing.",
            'racket': "which has a frame with strings for playing racquet sports.",
            'radiator': "which has a device for transferring heat in vehicles.",
            'radio': "which has a device for receiving audio broadcasts.",
            'radio telescope': "which has an instrument for observing radio waves.",
            'rain barrel': "which has a container for collecting rainwater.",
            'recreational vehicle': "which has a vehicle for traveling and camping.",
            'fishing casting reel': "which has a device for winding fishing line.",
            'reflex camera': "which has a camera with a mirror system for viewing.",
            'refrigerator': "which has an appliance for keeping food cold.",
            'remote control': "which has a device for operating electronic equipment wirelessly.",
            'restaurant': "which has a place for serving meals to customers.",
            'revolver': "which has a firearm with rotating chambers for bullets.",
            'rifle': "which has a long-barreled firearm for shooting.",
            'rocking chair': "which has a chair mounted on curved rockers.",
            'rotisserie': "which has a rotating device for cooking meat evenly.",
            'eraser': "which has a tool for removing pencil marks from paper.",
            'rugby ball': "which has an oval shape used in rugby games.",
            'ruler measuring stick': "which has a tool for measuring lengths accurately.",
            'sneaker': "which has a comfortable shoe designed for sports activities.",
            'safe': "which has a secure container for storing valuables.",
            'safety pin': "which has a fastening device for holding fabrics together.",
            'salt shaker': "which has a container for dispensing salt.",
            'sandal': "which has an open-toed footwear for warm weather.",
            'sarong': "which has a piece of cloth wrapped around the body.",
            'saxophone': "which has a brass instrument played with a reed.",
            'scabbard': "which has a protective sheath for a sword.",
            'weighing scale': "which has a device for measuring weight accurately.",
            'school bus': "which has a vehicle designed for transporting students.",
            'schooner': "which has a sailing ship with two or more masts.",
            'scoreboard': "which has a display showing scores in games.",
            'CRT monitor': "which has a bulky screen for displaying computer graphics.",
            'screw': "which has a metal fastener with a spiral thread.",
            'screwdriver': "which has a tool for turning screws with precision.",
            'seat belt': "which has a safety strap for securing passengers in vehicles.",
            'sewing machine': "which has a device for stitching fabric together.",
            'shield': "which has a protective barrier used in combat.",
            'shoe store': "which has a retail shop specializing in footwear.",
            'shoji screen / room divider': "which has a sliding partition for privacy.",
            'shopping basket': "which has a container for carrying groceries.",
            'shopping cart': "which has a wheeled vehicle for transporting goods.",
            'shovel': "which has a tool for digging or moving materials.",
            'shower cap': "which has a waterproof cover for protecting hair.",
            'shower curtain': "which has a barrier for keeping water contained in showers.",
            'ski': "which has a long narrow board for gliding on snow.",
            'balaclava ski mask': "which has a head covering for warmth in winter.",
            'sleeping bag': "which has a portable bedding for camping or travel.",
            'slide rule': "which has a mathematical tool for calculations and measurements.",
            'sliding door': "which has a door that moves horizontally to open.",
            'slot machine': "which has a gambling device for playing games of chance.",
            'snorkel': "which has a tube for breathing while swimming underwater.",
            'snowmobile': "which has a vehicle for traveling over snow-covered terrain.",
            'snowplow': "which has a vehicle for clearing snow from roads.",
            'soap dispenser': "which has a container for dispensing liquid soap.",
            'soccer ball': "which has a spherical ball used in soccer games.",
            'sock': "which has a garment for covering the foot.",
            'solar thermal collector': "which has a device for absorbing sunlight to generate heat.",
            'sombrero': "which has a wide-brimmed hat traditionally worn in Mexico.",
            'soup bowl': "which has a deep dish for serving soup.",
            'keyboard space bar': "which has a key used for creating spaces in text.",
            'space heater': "which has a portable device for heating small areas.",
            'space shuttle': "which has a spacecraft designed for travel to space.",
            'spatula': "which has a kitchen tool for flipping or spreading food.",
            'motorboat': "which has a boat powered by an engine.",
            'spider web': "which has a silken structure built by spiders.",
            'spindle': "which has a rod for twisting and spinning fibers.",
            'sports car': "which has a high-performance vehicle designed for speed.",
            'spotlight': "which has a powerful light focused on a specific area.",
            'stage': "which has a platform for performances and presentations.",
            'steam locomotive': "which has a train powered by steam engines.",
            'through arch bridge': "which has a bridge with a curved arch structure.",
            'steel drum': "which has a musical instrument made from a metal barrel.",
            'stethoscope': "which has a tool for listening to internal body sounds.",
            'scarf': "which has a piece of fabric worn around the neck.",
            'stone wall': "which has a structure built from stacked stones.",
            'stopwatch': "which has a device for measuring time intervals.",
            'stove': "which has a cooking appliance for heating food.",
            'strainer': "which has a device for separating liquids from solids.",
            'tram': "which has a rail vehicle for transporting passengers.",
            'stretcher': "which has a device for carrying injured persons.",
            'couch': "which has a comfortable piece of furniture for seating.",
            'stupa': "which has a dome-shaped structure used in Buddhism.",
            'submarine': "which has an underwater vessel for military or research purposes.",
            'suit': "which has a formal outfit typically worn for business.",
            'sundial': "which has a timekeeping device that uses the sun.",
            'sunglasses': "which has tinted lenses for protecting eyes from sunlight.",
            'sunscreen': "which has a lotion for protecting skin from UV rays.",
            'suspension bridge': "which has a bridge supported by cables and towers.",
            'mop': "which has a tool for cleaning floors with liquid.",
            'sweatshirt': "which has a casual garment for warmth and comfort.",
            'swim trunks / shorts': "which has a type of clothing for swimming.",
            'swing': "which has a seat suspended for swinging back and forth.",
            'electrical switch': "which has a device for controlling electrical circuits.",
            'syringe': "which has a tool for injecting or withdrawing fluids.",
            'table lamp': "which has a light fixture designed for tables.",
            'tank': "which has a heavily armored vehicle for combat.",
            'tape player': "which has a device for playing cassette tapes.",
            'teapot': "which has a vessel for brewing and serving tea.",
            'teddy bear': "which has a soft stuffed toy resembling a bear.",
            'television': "which has a device for receiving and displaying video signals.",
            'tennis ball': "which has a lightweight ball used in tennis matches.",
            'thatched roof': "which has a roof made of straw or reeds.",
            'front curtain': "which has a fabric barrier for stage performances.",
            'thimble': "which has a small cap worn on a finger while sewing.",
            'threshing machine': "which has a device for separating grain from husks.",
            'throne': "which has an ornate chair for a monarch or leader.",
            'tile roof': "which has a roof covered with tiles for protection.",
            'toaster': "which has an appliance for browning slices of bread.",
            'tobacco shop': "which has a retail store selling tobacco products.",
            'toilet seat': "which has a hinged seat for a toilet.",
            'torch': "which has a portable light source using flame.",
            'totem pole': "which has a carved pole representing cultural symbols.",
            'tow truck': "which has a vehicle for towing broken down cars.",
            'toy store': "which has a retail shop selling toys for children.",
            'tractor': "which has a powerful vehicle for agricultural work.",
            'semi-trailer truck': "which has a large vehicle for transporting goods.",
            'tray': "which has a flat dish for carrying items.",
            'trench coat': "which has a long coat designed for protection against rain.",
            'tricycle': "which has a three-wheeled vehicle for children.",
            'trimaran': "which has a boat with three parallel hulls.",
            'tripod': "which has a three-legged stand for stabilizing equipment.",
            'triumphal arch': "which has a monumental arch commemorating victories.",
            'trolleybus': "which has a bus powered by overhead electric wires.",
            'trombone': "which has a brass musical instrument with a slide.",
            'hot tub': "which has a large tub for soaking in hot water.",
            'turnstile': "which has a rotating gate allowing entry for one person.",
            'typewriter keyboard': "which has a mechanical keyboard for typing text.",
            'umbrella': "which has a handheld device for protection from rain.",
            'unicycle': "which has a single-wheeled vehicle for balance.",
            'upright piano': "which has a vertical piano design for playing music.",
            'vacuum cleaner': "which has a device for sucking up dirt and debris.",
            'vase': "which has a container for holding flowers or decorative items.",
            'vaulted or arched ceiling': "which has a ceiling with a curved or peaked shape.",
            'velvet fabric': "which has a soft, luxurious textile with a rich texture.",
            'vending machine': "which has a machine for dispensing snacks and drinks.",
            'vestment': "which has ceremonial garments worn by clergy.",
            'viaduct': "which has a bridge that carries a road over a valley.",
            'violin': "which has a string instrument played with a bow.",
            'volleyball': "which has a lightweight ball used in volleyball games.",
            'waffle iron': "which has a device for making waffle-shaped pastries.",
            'wall clock': "which has a timekeeping device mounted on a wall.",
            'wallet': "which has a small case for carrying money and cards.",
            'wardrobe': "which has a cabinet for storing clothes.",
            'military aircraft': "which has a plane designed for military operations.",
            'sink': "which has a basin for holding water in kitchens or bathrooms.",
            'washing machine': "which has a device for cleaning clothes automatically.",
            'water bottle': "which has a container for holding drinking water.",
            'water jug': "which has a large container for storing liquids.",
            'water tower': "which has a tall structure for storing and distributing water.",
            'whiskey jug': "which has a container for holding whiskey.",
            'whistle': "which has a small device for producing a high-pitched sound.",
            'hair wig': "which has a head covering made from artificial or real hair.",
            'window screen': "which has a mesh covering for windows to keep insects out.",
            'window shade': "which has a covering for blocking light from windows.",
            'Windsor tie': "which has a type of necktie known for its wide knot.",
            'wine bottle': "which has a container for holding and storing wine.",
            'airplane wing': "which has a structure that provides lift for aircraft.",
            'wok': "which has a round-bottomed cooking pan for stir-frying.",
            'wooden spoon': "which has a kitchen utensil for stirring or serving food.",
            'wool': "which has a soft textile made from sheep's fleece.",
            'split-rail fence': "which has a rustic fence made from split logs.",
            'shipwreck': "which has a sunken vessel lost at sea.",
            'sailboat': "which has a boat powered by sails for navigation.",
            'yurt': "which has a portable, circular dwelling used by nomads.",
            'website': "which has a collection of interconnected web pages.",
            'comic book': "which has a publication featuring sequential art and stories.",
            'crossword': "which has a word puzzle filled with intersecting words.",
            'traffic or street sign': "which has a sign conveying information to drivers.",
            'traffic light': "which has a signaling device controlling vehicle traffic.",
            'dust jacket': "which has a protective cover for a book.",
            'menu': "which has a list of food and drink items available.",
            'plate': "which has a flat dish for serving food.",
            'guacamole': "which has a creamy avocado dip often served with chips.",
            'consomme': "which has a clear soup made from concentrated stock.",
            'hot pot': "which has a dish for cooking food in simmering broth.",
            'trifle': "which has a layered dessert featuring fruits and cream.",
            'ice cream': "which has a frozen dessert made from milk and sugar.",
            'popsicle': "which has a frozen treat on a stick, usually fruity.",
            'baguette': "which has a long, thin loaf of French bread.",
            'bagel': "which has a round bread roll with a hole in the middle.",
            'pretzel': "which has a twisted bread snack often sprinkled with salt.",
            'cheeseburger': "which has a sandwich with a meat patty and cheese.",
            'hot dog': "which has a cooked sausage served in a bun.",
            'mashed potatoes': "which has a creamy side dish made from boiled potatoes.",
            'cabbage': "which has a leafy green vegetable often used in salads.",
            'broccoli': "which has a green vegetable resembling a small tree.",
            'cauliflower': "which has a white vegetable similar to broccoli.",
            'zucchini': "which has a green summer squash used in various dishes.",
            'spaghetti squash': "which has a yellow vegetable with stringy flesh when cooked.",
            'acorn squash': "which has a sweet, nutty-flavored winter squash variety.",
            'butternut squash': "which has a sweet, creamy-textured winter squash.",
            'cucumber': "which has a refreshing, crunchy vegetable often in salads.",
            'artichoke': "which has a thistle-like vegetable known for its edible buds.",
            'bell pepper': "which has a sweet, colorful vegetable used in cooking.",
            'cardoon': "which has a thistle-like vegetable related to artichokes.",
            'mushroom': "which has a fungal growth commonly used in cooking.",
            'Granny Smith apple': "which has a tart, green apple variety used for baking.",
            'strawberry': "which has a sweet red berry with tiny seeds on top.",
            'orange': "which has a round citrus fruit known for its juice.",
            'lemon': "which has a yellow citrus fruit known for its sour taste.",
            'fig': "which has a sweet fruit with a unique texture.",
            'pineapple': "which has a tropical fruit with a spiky exterior.",
            'banana': "which has a long, curved fruit with a yellow peel.",
            'jackfruit': "which has a large tropical fruit with a sweet taste.",
            'cherimoya (custard apple)': "which has a creamy, custard-like fruit with seeds.",
            'pomegranate': "which has a fruit filled with juicy seeds inside.",
            'hay': "which has dried grass or plants used for animal feed.",
            'carbonara': "which has an Italian pasta dish with creamy sauce.",
            'chocolate syrup': "which has a sweet sauce made from chocolate.",
            'dough': "which has a mixture of flour and water used for baking.",
            'meatloaf': "which has a baked dish made from ground meat and seasonings.",
            'pizza': "which has a flatbread topped with cheese and various ingredients.",
            'pot pie': "which has a savory dish with a pastry crust and filling.",
            'burrito': "which has a tortilla wrapped around filling of meats and beans.",
            'red wine': "which has a type of wine made from dark grapes.",
            'espresso': "which has a strong coffee brewed by forcing steam.",
            'tea cup': "which has a small cup for serving tea.",
            'eggnog': "which has a creamy beverage made with eggs and milk.",
            'mountain': "which has towering peaks and rugged terrain.",
            'bubble': "which has a spherical air-filled film of liquid.",
            'cliff': "which has a steep rock face or overhang.",
            'coral reef': "which has a vibrant underwater ecosystem of corals.",
            'geyser': "which has a natural hot spring that erupts periodically.",
            'lakeshore': "which has a scenic edge of a freshwater lake.",
            'promontory': "which has a high landform overlooking a body of water.",
            'sandbar': "which has a ridge of sand formed by water currents.",
            'beach': "which has a sandy shore by the ocean or sea.",
            'valley': "which has a low area between mountains or hills.",
            'volcano': "which has an opening in the earth's crust spewing lava.",
            'baseball player': "which has an athlete who plays the sport of baseball.",
            'bridegroom': "which has a man on his wedding day.",
            'scuba diver': "which has a person using equipment to explore underwater.",
            'rapeseed': "which has bright yellow flowers commonly grown for oil.",
            'daisy': "which has a flower with white petals and a yellow center.",
            "yellow lady's slipper": "which has a unique orchid with a yellow pouch-like bloom.",
            'corn': "which has tall plants bearing ears of yellow kernels.",
            'acorn': "which has a nut of the oak tree, typically brown.",
            'rose hip': "which has a red fruit of the wild rose plant.",
            'horse chestnut seed': "which has a large, shiny seed encased in a spiky shell.",
            'coral fungus': "which has a distinctive, branched fungal structure resembling coral.",
            'agaric': "which has a type of mushroom with a cap and stem.",
            'gyromitra': "which has a mushroom known for its lobed shape.",
            'stinkhorn mushroom': "which has a foul-smelling fungus, often shaped like a horn.",
            'earth star fungus': "which has a star-shaped mushroom found in soil.",
            'hen of the woods mushroom': "which has a cluster of frilled, fan-shaped caps.",
            'bolete': "which has a type of mushroom with a spongy underside.",
            'corn cob': "which has a central core surrounded by yellow kernels.",
            'toilet paper': "which has soft, absorbent sheets for personal hygiene."
        }
    
    @staticmethod
    def read_classnames(text_file):
        """Return a dictionary containing
        key-value pairs of <folder name>: <class name>.
        """
        classnames = OrderedDict()
        with open(text_file, "r") as f:
            lines = f.readlines()
            for line in lines:
                line = line.strip().split(" ")
                folder = line[0]
                classname = " ".join(line[1:])
                classnames[folder] = classname
        return classnames

    def read_data(self, classnames, split_dir):
        split_dir = os.path.join(self.image_dir, split_dir)
        folders = sorted(f.name for f in os.scandir(split_dir) if f.is_dir())
        items = []

        for label, folder in enumerate(folders):
            imnames = listdir_nohidden(os.path.join(split_dir, folder))
            classname = classnames[folder]
            for imname in imnames:
                impath = os.path.join(split_dir, folder, imname)
                item = Datum(impath=impath, label=label, classname=classname)
                items.append(item)

        return items